<?php
class Data_exportExcel {
	function exportExcel($name, $dataDir, $dataArr, $keyValues) {
			
			$excelData = array();
			// 表头
			$excelRs = array();
			foreach($keyValues as $key => $val) {
				$excelRs[0][] = $val;
			}
			
			//数据内容	
			foreach ($dataArr as $key=>$val) {
				foreach($keyValues as $k => $v)	{
					$arr[] = $val[$k];
				}
				$excelData[] = $arr;
				$arr = array();
			}

			$excelData = array_merge($excelRs, $excelData);
			
			
			$writeExcelArr[0]['name'] = "data";
			$writeExcelArr[0]['data'] = $excelData;
			
			$excelPath = ROOT_PATH . "/export/{$dataDir}/" . $name . ".xls";
			$rs = MooObj::get('Control_ExcelConfMaker_Excel')->write($excelPath, $writeExcelArr);
			MooUtil::downFile($excelPath, $name . ".xls");
	}
}